//
//  SiJiCell.m
//  NtoccDriverNew
//
//  Created by 文 on 2019/12/20.
//  Copyright © 2019 GCY. All rights reserved.
//

#import "DriverApplyJoinCell.h"

@interface DriverApplyJoinCell ()
@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UILabel *chexingLabel;
@property (weak, nonatomic) IBOutlet UILabel *chepaiLabel;
@property (weak, nonatomic) IBOutlet UILabel *carInfoLabel;
@property (weak, nonatomic) IBOutlet UIView *line;
@property (weak, nonatomic) IBOutlet UILabel *nicknameLabel;
@property (nonatomic, strong) GQRatingView *ratingView;
@property (nonatomic, strong) UILabel *scoreLabel;
@property (weak, nonatomic) IBOutlet UIImageView *selectedImageView;
@property (weak, nonatomic) IBOutlet UIButton *agreeButton;
@property (weak, nonatomic) IBOutlet UIButton *refusedButton;
@property (strong, nonatomic) UILabel *statusTextLabel;

@end

@implementation DriverApplyJoinCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    _nicknameLabel.textColor = Dark_TextColor;
    _chexingLabel.textColor = Light_TextColor;
    _chepaiLabel.textColor = Light_TextColor;
    _carInfoLabel.textColor = Light_TextColor;
    _line.backgroundColor = BackgroundColor;
    
    _scoreLabel = [[UILabel alloc] init];
    _scoreLabel.textColor = Light_TextColor;
    _scoreLabel.font = font(13);
    [self addSubview:_scoreLabel];
    
    [_agreeButton setBackgroundColor:Blue_TextColor];
    
    [_refusedButton setBackgroundColor:Orange_Color];
    
    //五角星 链式调用 [NSNumber numberWithInt:_model.avgBasicGrade]
    _ratingView = [GQRatingView init]
    .frameChain(CGPointMake(_headImageView.cy_right + 15, _nicknameLabel.cy_y + 3),15)
    .canTouchChain(NO)
    .needIntValueChain(NO)
    .scoreNumChain([NSNumber numberWithFloat:_model.avgBasicGrade])
    .normalColorChain([UIColor cy_colorWithHexString:@"#C0CDDE"])
    .highlightColorChian([UIColor cy_colorWithHexString:@"#FFC000"])
    .scroreBlockChain(^(NSNumber *scoreNumber){
    }).superViewChain(self);
    
    _statusTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _carInfoLabel.cy_bottom + 10, ScreenW, 30)];
    _statusTextLabel.textColor = Dark_TextColor;
    _statusTextLabel.text = @"-";
    _statusTextLabel.font = font(16);
    _statusTextLabel.hidden = YES;
    _statusTextLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_statusTextLabel];
}


- (IBAction)buttonTypeClick:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(cellButtonIndexClick:withButton:)]) {
        [self.delegate cellButtonIndexClick:sender.tag withButton:sender];
    }
}

- (void)setModel:(DriverApplyRecordModel *)model {
    
    _model = model;
    
    
    setNetImage(_headImageView, _model.headImg, @"img_siji_dHead");
    _nicknameLabel.text = _model.name;
    _scoreLabel.text = CJStringWithFormat(@"%.1f",_model.avgBasicGrade);
    _chexingLabel.text = CJStringWithFormat(@"车型：%@",_model.vehicleClassificationName);
    _chepaiLabel.text = _model.vehicleLicenseNumber;
    _carInfoLabel.text = CJStringWithFormat(@"状态：%@ | 吨位：%@ | 车数：%ld辆",_model.vehicleLoadStatusName, _model.vehicleLoadWeightName, (long)_model.balance);
    
    CGSize size = [DCSpeedy dc_calculateTextSizeWithText:_model.name WithTextFont:14 WithMaxW:1000];
    
    _ratingView.cy_x = _headImageView.cy_right + 15 + size.width;
    _ratingView.scoreNum = [NSNumber numberWithFloat:_model.avgBasicGrade];
    
    _scoreLabel.frame = CGRectMake(_headImageView.cy_right + 15 + size.width + 80, _nicknameLabel.cy_y + 1, 60, 20);

    //    status
//        状态：0未处理，1已同意，2已拒绝
    if (model.status == 0) {
        _agreeButton.hidden = NO;
        _refusedButton.hidden = NO;
        _statusTextLabel.hidden = YES;

    } else{
        _agreeButton.hidden = YES;
        _refusedButton.hidden = YES;
        _statusTextLabel.hidden = NO;

        if (model.status == 1) {
            _statusTextLabel.text = @"已同意";
        } else {
            _statusTextLabel.text = @"已拒绝";
        }
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
